package main

import (
	"fmt"
	"github.com/gomodule/redigo/redis"
)

func main() {
	conn, err := redis.Dial("tcp", "192.168.3.108:6379")
	if err != nil {
		fmt.Println("连接Redis ERROR:", err)
		return
	}
	fmt.Println("连接Redis 成功:", conn)
	defer conn.Close()

	resSet, err := conn.Do("Set", "age", 18)  // 这里存字符串或数值到Redis里都是一样的
	if err != nil {
		fmt.Println("Set Redis ERROR:", err)
		return
	}
	fmt.Println("Redis Set:", resSet)

	resGet, err := redis.Int(conn.Do("Get", "age"))
	if err != nil {
		fmt.Println("Get Redis ERROR:", err)
		return
	}
	fmt.Println("Redis Get:", resGet)
}